home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / ODF Release 3 / ODFDev / Draw / Sources / DrawSel.h < prev    next >
Encoding:
Text File  |  1996-12-16  |  7.4 KB  |  235 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                DrawSel.h
  4. //    Release Version:    $ ODF 3 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef DRAWSEL_H
  13. #define DRAWSEL_H
  14.  
  15. #ifndef DRAWLINK_H
  16. #include "DrawLink.h"
  17. #endif
  18.  
  19. // ----- Part Layer -----
  20.  
  21. #ifndef FWSELECT_H
  22. #include "FWSelect.h"
  23. #endif
  24.  
  25. // ----- OS Layer -----
  26.  
  27. #ifndef FWRECT_H
  28. #include "FWRect.h"
  29. #endif
  30.  
  31. #ifndef FWRECSHP_H
  32. #include "FWRecShp.h"
  33. #endif
  34.  
  35. //========================================================================================
  36. //    Forward Declarations
  37. //========================================================================================
  38.  
  39. class FW_CGraphicContext;
  40. class FW_CMouseEvent;
  41.  
  42. class CDrawPart;
  43. class CDrawFrame;
  44. class CSelectionIterator;
  45. class CDrawSelection;
  46. class CBaseShape;
  47.  
  48. class CDrawContent;
  49. class CDrawSelectionContent;
  50.  
  51. //========================================================================================
  52. //    class CDrawSelection
  53. //========================================================================================
  54.  
  55. class CDrawSelection : public FW_CSelection
  56. {
  57. //----------------------------------------------------------------------------------------
  58. //    Initialization/Destruction
  59. //
  60. public:
  61.     FW_DECLARE_AUTO(CDrawSelection)
  62.  
  63.     CDrawSelection(Environment* ev, CDrawPart* drawPart);
  64.     virtual         ~CDrawSelection();
  65.     
  66. //----------------------------------------------------------------------------------------
  67. //    Inherited API
  68. //
  69. public:
  70.     virtual void        CloseSelection(Environment* ev);
  71.     virtual void        SelectAll(Environment* ev);
  72.     virtual FW_Boolean    IsEmpty(Environment* ev) const;
  73.     virtual void        ClearSelection(Environment* ev);
  74.     
  75.     virtual FW_CContent* GetSelectedContent(Environment* ev);
  76.     
  77.     virtual ODShape*    AcquireSelectionShape(Environment* ev, ODFacet* facet, FW_CFrame* frame);
  78.     virtual ODShape*    AcquireSelectionOutline(Environment* ev, ODFacet* facet, FW_CFrame* frame);
  79.     
  80.     virtual FW_Boolean    CanPasteAsLink(Environment* ev, ODPasteAsMergeSetting& setting, ODStorageUnit* su);
  81.     virtual FW_Boolean    IsSelectionLinkable(Environment* ev);
  82.     
  83.     virtual FW_Boolean    IsMouseInDraggableItem(Environment* ev, 
  84.                             FW_CFrame* frame,
  85.                             const FW_CMouseEvent& theMouseEvent, 
  86.                             FW_Boolean inBackground);
  87.  
  88.     virtual void        UpdateSelectionOnMouseDown(Environment* ev, 
  89.                             const FW_CMouseEvent& mouseEvent,
  90.                             ODFacet* embeddedFacet,
  91.                             FW_Boolean inEmbeddedFrameBorder,
  92.                             FW_Boolean inBackground);
  93.     
  94.     virtual FW_CLinkDestination* GetLinkDestination(Environment* ev, FW_Boolean& multipleLinks);
  95.  
  96. //----------------------------------------------------------------------------------------
  97. //    New API
  98. //
  99. public:
  100.     CBaseShape*     WhichHandle(Environment* ev, FW_CGraphicContext& gc, const FW_CPoint& mouse, short& whichHandle, FW_Fixed zoomFactor) const;
  101.     
  102.     void            RenderSelectionHandles(Environment* ev, FW_CGraphicContext& gc, FW_Fixed zoomFactor);
  103.     void            InvalidateSelectionHandles(Environment* ev, CDrawFrame* frame);
  104.     
  105.     void            RenderHandles(Environment* ev, CBaseShape* shape);
  106.     void            RenderAllHandles(Environment* ev, CDrawFrame* frame);
  107.     
  108.     void            AddToSelection(Environment* ev, CBaseShape* theShape, FW_Boolean renderHandles);
  109.     void            RemoveFromSelection(Environment* ev, CBaseShape* theShape, FW_Boolean renderHandles);
  110.  
  111.     void            OffsetSelection(Environment* ev, FW_Fixed xDelta, FW_Fixed yDelta);
  112.  
  113.     FW_Boolean        Resize(Environment* ev, const FW_CMouseEvent& theMouseEvent);    
  114.  
  115.     void            SelectWithRectangle(Environment* ev, const FW_CMouseEvent& theMouseEvent);
  116.  
  117.     FW_Boolean        GetSelectionPenSize(Environment* ev, FW_Fixed& penSize);
  118.  
  119.     FW_CPoint        CenterSelection(Environment* ev, FW_CFrame* scopeFrame);
  120.     
  121.     unsigned long    Count() const;
  122.     
  123.     // ----- Frozen state -----
  124.     FW_Boolean        HasFrozen() const;
  125.     FW_Boolean        HasNotFrozen() const;
  126.     void            SetFrozen(Environment* ev, FW_Boolean state);
  127.     
  128.     ODShape*        GetUpdateShape() const;
  129.     const FW_CRect&    GetDragRect() const;
  130.  
  131.     // ----- Anchor Shape -----
  132.     CBaseShape*        GetAnchorShape() const;
  133.     void            SetAnchorShape(CBaseShape* shape);
  134.  
  135.  
  136.     // ----- Linking -----
  137.     void             SelectionChanged(Environment* ev, ODUpdateID updateID);
  138.     void            DeleteSelection(Environment* ev);
  139.  
  140.     void            CalcCache(Environment* ev);
  141.  
  142. private:
  143.     
  144.     void            DoAdd(Environment* ev, CBaseShape *shape);
  145.     void            DoRemove(Environment* ev, CBaseShape *shape);
  146.         
  147. public:
  148.     void            ShapeAdded(Environment* ev, CBaseShape* shape);
  149.     void            SelectContent(Environment* ev, CDrawContent* content);
  150.     CDrawContent*    GetDrawContent(Environment* ev);
  151.     CDrawPart*        GetDrawPart() const
  152.                         {return fDrawPart;}
  153.     CDrawPublishLinkCollection* GetSelectedLinkSources();
  154.     virtual FW_CLinkSource* DoFindLinkSource(Environment* ev);
  155.  
  156.  
  157. //----------------------------------------------------------------------------------------
  158. //    Data Members
  159. //
  160. private:
  161.     CDrawPart*            fDrawPart;
  162.     FW_CRect            fDragRect;
  163.     ODShape*            fUpdateShape;
  164.     unsigned short        fFrozenCount;
  165.     unsigned long        fCount;
  166.     CBaseShape*            fAnchorShape;
  167.     short                fClickedHandle;
  168.     
  169.     CDrawSelectionContent*    fSelectionContent;
  170.     
  171.     FW_CRectShape        fWorkingHandle;
  172.     CDrawSelectionContent*    fDraggedContent;
  173. };
  174.  
  175. //========================================================================================
  176. //    CDrawSelection Inlines
  177. //========================================================================================
  178.  
  179. //----------------------------------------------------------------------------------------
  180. //    CDrawSelection::GetUpdateShape
  181. //----------------------------------------------------------------------------------------
  182. inline ODShape* CDrawSelection::GetUpdateShape() const
  183. {        
  184.     return fUpdateShape;
  185. }
  186.  
  187. //----------------------------------------------------------------------------------------
  188. //    CDrawSelection::GetDragRect
  189. //----------------------------------------------------------------------------------------
  190. inline const FW_CRect& CDrawSelection::GetDragRect() const
  191. {        
  192.     return fDragRect;
  193. }
  194.  
  195. //----------------------------------------------------------------------------------------
  196. //    CDrawSelection::HasFrozen
  197. //----------------------------------------------------------------------------------------
  198. inline FW_Boolean CDrawSelection::HasFrozen() const
  199. {
  200.     return fFrozenCount != 0;
  201. }
  202.  
  203. //----------------------------------------------------------------------------------------
  204. //    CDrawSelection::HasNotFrozen
  205. //----------------------------------------------------------------------------------------
  206. inline FW_Boolean CDrawSelection::HasNotFrozen() const
  207. {
  208.     return fCount != 0 && fFrozenCount != fCount;
  209. }
  210.  
  211. //----------------------------------------------------------------------------------------
  212. //    CDrawSelection::Count
  213. //----------------------------------------------------------------------------------------
  214. inline unsigned long CDrawSelection::Count() const
  215. {
  216.     return fCount;
  217. }
  218.  
  219. //----------------------------------------------------------------------------------------
  220. //    CDrawSelection::GetAnchorShape
  221. //----------------------------------------------------------------------------------------
  222. inline CBaseShape* CDrawSelection::GetAnchorShape() const
  223. {
  224.     return fAnchorShape;
  225. }
  226.  
  227. //----------------------------------------------------------------------------------------
  228. //    CDrawSelection::SetAnchorShape
  229. //----------------------------------------------------------------------------------------
  230. inline void CDrawSelection::SetAnchorShape(CBaseShape* shape)
  231. {
  232.     fAnchorShape = shape;
  233. }
  234.  
  235. #endif